const path = require("path")
const webpack = require('webpack')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const htmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = {
    devServer: {
        contentBase: './public'
    },
    entry: './src/main.js',
    output: {
        path: path.resolve(__dirname, "./dist"),
        filename: 'bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: /node_modules/,
            },
            {
                test: /\.js$/, 
                exclude: /node_modules/, 
                use: 'eslint-loader',
                enforce:"pre"  //优先级最高
              },
            {
                test: /\.vue$/,
                loader: ['vue-loader'],
                exclude: /node_modules/,
            },

            {
                test: /\.less$/,
                use: ['style-loader', 'css-loader', 'less-loader'],
                exclude: /node_modules/,
            },
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader'
                ],
                exclude: /node_modules/,
            },
            {
                test: /\.(png|jpg|gif)$/,
                use: [
                    {
                        loader: 'url-loader',
                        options: {
                            limit: 10 * 1024,//10k一下url-loader处理 以上自动使用file-loader
                            esModule: false
                        }
                    }
                ],
                exclude: /node_modules/,

            }
        ]
    },
    plugins: [
        new webpack.DefinePlugin({BASE_URL: JSON.stringify('')}),
        new VueLoaderPlugin(),
        new htmlWebpackPlugin({
            title: 'spa单页应用',
            filename: 'index.html',
            template: './public/index.html',
        })
    ],
}